var fs = require('fs');

module.exports = {
    walkFiles: walkFiles 
}

// 递归遍历目录,返回文件列表
function walkFiles( path ) {
    var fileList = [];
    function walk( path ) {
        var dirList = fs.readdirSync(path);

        for( var i = 0; i < dirList.length; i++ ) {
            var item = dirList[i];
            if ( fs.statSync(path + '/' + item).isFile() ) {
                fileList.push( path + '/' + item );
            }
        }
        
        for( var i = 0; i < dirList.length; i++ ) {
            var item = dirList[i];
            if( fs.statSync(path + '/' + item).isDirectory() ) {
                if ( item.substring(0,1) == "." ) {
                    console.log("不需要隐藏目录");
                } else {
                    walk(path + '/' + item);
                }
            }
        }
    }
    
    walk( path );
    
    return fileList;
}